package Person.ith_28;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Collectiona {
    public static void main(String[] args) {
        Collection<Student> c= new ArrayList<Student>();
        Student s1= new Student("林一",30);
        //s1.setAge(10);
        //s1.setName("林一");
        Student s2= new Student("林",3);
        Student s3= new Student("一",10);
        //把学生添加到集合
        c.add(s1);
        c.add(s2);
        c.add(s3);
        //遍历集合（迭代器方法）
        Iterator<Student> it = c.iterator();
        while(it.hasNext()){

            Student s = it.next();
            System.out.println(s.getname()+","+s.getAge());
        }


    }
}
